

function User(name, age) {
	this.name = name;
	this.age = age;
}
User.prototype.show = function() {
	console.log(this.name, this.age);
};


// 对象工厂派生对象并实现继承
function admin(name, age) {
	const instance = Object.create(User.prototype);
	User.call(instance, name, age);

	instance.role = function() {
		console.log("role");
	};
	return instance;
}
var hd = admin("向军", 19);
hd.show();
hd.role();


var hd2 = admin("阿曼", 18);
hd2.show();
hd2.role();

console.log(hd2)
// show 原型的方法 true
console.log(hd.show == hd2.show)
// role 实例上的方法 false
console.log(hd.role == hd2.role)
console.log('-----------------------\n')




function member(name, age) {
	const instance = Object.create(User.prototype);
	User.call(instance, name, age);
	return instance;
}

let lisi = member("李四", 23);
lisi.show();